package api

import (
	"CodeCover/internal/db"
	"CodeCover/internal/handler"
	"CodeCover/internal/respository"
	"CodeCover/internal/service"
	"os"
	"path/filepath"

	"github.com/gin-gonic/gin"
)

func StartRoute(r *gin.Engine) {

	sqlTaskRepo := respository.NewMysqlTaskRepository(db.SqlDB)
	sqlUserRepo := respository.NewMysqlUserRepository(db.SqlDB)

	taskSvc := service.NewTaskService(sqlTaskRepo)
	userSvc := service.NewUserService(sqlUserRepo)

	homeDir, _ := os.UserHomeDir()
	gitSvc := service.NewGitService(filepath.Join(homeDir, "coderepos"))
	taskHandler := handler.NewExecuteHandler(taskSvc, userSvc, gitSvc)

	r.POST("/start", taskHandler.GetRq)
}
